package com.cskaoyan.service.dashboard;

import com.cskaoyan.bean.MallGoodsExample;
import com.cskaoyan.bean.MallGoodsProductExample;
import com.cskaoyan.bean.MallOrderGoodsExample;
import com.cskaoyan.bean.MallUserExample;
import com.cskaoyan.mapper.MallGoodsMapper;
import com.cskaoyan.mapper.MallGoodsProductMapper;
import com.cskaoyan.mapper.MallOrderGoodsMapper;
import com.cskaoyan.mapper.MallUserMapper;
import com.cskaoyan.model.vo.dashboard.DashboardData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: project-market
 * @description:
 * @author: zhijie
 * @create: 2021-11-29 23:21
 **/
@Service
public class DashboardServiceImpl implements DashboardService {
    @Autowired
    MallGoodsMapper mallGoodsMapper;
    @Autowired
    MallGoodsProductMapper mallGoodsProductMapper;
    @Autowired
    MallOrderGoodsMapper mallOrderGoodsMapper;
    @Autowired
    MallUserMapper mallUserMapper;
    @Override
    public DashboardData dashboard() {
        long goodsTotal = mallGoodsMapper.countByExample(new MallGoodsExample());
        long productTotal = mallGoodsProductMapper.countByExample(new MallGoodsProductExample());
        long orderTotal = mallOrderGoodsMapper.countByExample(new MallOrderGoodsExample());
        long userTotal = mallUserMapper.countByExample(new MallUserExample());
        DashboardData data = new DashboardData();
        data.setGoodsTotal(goodsTotal);
        data.setOrderTotal(orderTotal);
        data.setProductTotal(productTotal);
        data.setUserTotal(userTotal);
        return data;
    }
}
